home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11294 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.ncl.ac.uk!aidan!n5013784
  2. From: Tom Seddon <T.W.Seddon@ncl.ac.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: What happens on realloc() failure?
  5. Date: Fri, 22 Mar 1996 19:37:44 +0000
  6. Organization: University of Newcastle upon Tyne
  7. Message-ID: <Pine.SOL.3.91-941213.960322192958.24127A-100000@aidan.ncl.ac.uk>
  8. NNTP-Posting-Host: aidan.ncl.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. I am writing a program which will need to call realloc() a fair amount. 
  13. What I would like to know is whether the original data is still usable if
  14. the realloc() fails. (Although it is unlikely that there will be problems
  15. with running out of memory, it is possible that there will be problems due
  16. to fragmentation of memory.)
  17.  
  18. Since realloc() returns NULL on failure, is it safe to use the pointer to 
  19. the malloc()ed area I was trying to resize? Or will the old area have 
  20. been freed by free() and now be unusable? What does the ANSI standard 
  21. have to say about this? I've never seen anything about this point before 
  22. (although if it's in the FAQ I apologise, I must have missed it :-( )
  23.  
  24. I'm using djgpp 1.12maint2 on a 486 so if anyone has some djgpp-specific
  25. information I'd be most grateful. My program is djgpp/386+/DOS specific so
  26. I'm not bothered at all about portability problems. 
  27.  
  28. Thanks in advance,
  29.  
  30. --Tom
  31.  
  32.     |     ** Tom Seddon **      E-mail: T.W.Seddon@ncl.ac.uk
  33.   - . -                 www: http://www.ncl.ac.uk/~n5013784/
  34.    /|\
  35.   //|\\   If you help a friend in need, he's sure to remember you...
  36.  ///|\\\  next time he's in need.
  37. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  38.  
  39.